function out = solve_P(pi1,pi2,p11,p22,p3)


P = [ p11*(1-pi1)      (1-p11)*(1-pi1)  pi1;
    (1-p22)*(1-pi2)    p22*(1-pi2)      pi2;
    (1-p3)/2           (1-p3)/2         p3];

stat    = P^1e6;
stat    = stat(1,:)';

out = stat(3);